package com.yang.controller;


import com.yang.pojo.Person;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;

@RequestMapping("/file/upload")
@RestController
public class FileUploadController {

    /**
     * 上传文件
     * @RequestPart(value="提交文件的键名")，若不指定value，默认为变量名
     *  可以用MultipartFile[]来接收多个文件上传
     */
    @PostMapping
    public String fileUpload(@RequestPart(value = "photo") MultipartFile[] file){

        System.out.println(Arrays.toString(file));
        return file!=null?"接收成功":"接收失败";
    }



}
